﻿using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.OpenSsl;
using Org.BouncyCastle.Security;
using System;
using System.Collections.Generic;
using System.IO;
using System.Security.Cryptography;
using System.Text;
namespace Odyssey.BouncyCastle.SMUtil
{
    using Implementations;
    public class OdysseySM
    {

        public static ISMDispatch BuildRSADispatch(string userId, string publicKey, string privateKey = "")
        {
            if (string.IsNullOrEmpty(privateKey) && string.IsNullOrEmpty(publicKey))
            {
                throw new Exception("Build sm disaptch faild!public and private keys must not be empty at the same time");
            }


            return new SMDispatch(userId, privateKey, publicKey);
        }

        public static List<string> GeneratKeys()
        {
            var listKeys = SMDispatch.GeneratKeys();

            return listKeys;
        }

        public static string CompressPubKey(string longPK)
        {
            return SMDispatch.CompressPubKey(longPK);
        }

        public static string UnCompressPubKey(string compressedPK)
        {
            return SMDispatch.UnCompressPubKey(compressedPK);
        }
    }
}
